import { createSlice } from '@reduxjs/toolkit';

const slice = createSlice({
  name: 'person',
  initialState: {
    value: [{ id: '001', name: 'tom', age: 18 }],
  },
  reducers: {
    addPerson: (state, action) => {
      state.value = [action.payload, ...state.value];
    },
  },
});

export const { addPerson } = slice.actions;
export default slice.reducer;
